package com.inspur.edp.bef.bemanager.codegenerator.genutils;

import com.inspur.edp.bef.bizentity.GspBizEntityObject;
import com.inspur.edp.caf.generator.baseInfo.CompilationUnitInfo;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import com.inspur.edp.cef.designtime.core.utilsgenerator.DataTypeUtilsGenerator;
import com.inspur.edp.das.commonmodel.IGspCommonObject;

import java.util.ArrayList;

public final class BeEntityUtilsGenerator extends DataTypeUtilsGenerator {
    private final GspBizEntityObject bizEntityObject;
    private String pachageName;

    public BeEntityUtilsGenerator(GspBizEntityObject bizEntityObject,String pachageName,String basePath) {
        super(bizEntityObject,basePath);
        this.bizEntityObject = bizEntityObject;
        this.pachageName = pachageName;
    }

    @Override
    protected String getClassName() {
        return bizEntityObject.getCode()+"Utils";
    }

    @Override
    protected String getClassPackage() {
        return pachageName;
    }

    @Override
    protected void generateExtendInfos() {
        super.generateExtendInfos();
        generateGetChildObjectDatas();
    }

    private void generateGetChildObjectDatas() {
        if(bizEntityObject.getContainChildObjects()==null||bizEntityObject.getContainChildObjects().size()==0)
            return;
        for(IGspCommonObject childObject:bizEntityObject.getContainChildObjects())
        {
            new EntityGetChildDatasMethodGenerator(childObject.getCode(),getClassInfo()).generate();
        }
    }
}
